package com.autcar.training.service;

import com.autcar.training.dao.WorkerMapper;
import com.autcar.training.entity.Worker;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ProjectName: training
 * @Package: com.autcar.training.service
 * @ClassName: WorkerServiceImpl
 * @Author: YHHHH
 * @Description:
 * @Date: 2020/8/30 16:09
 * @Version: 1.0
 */
@Service
public class WorkerServiceImpl implements WorkerService {
    @Resource
    private WorkerMapper workerMapper;

    @Override
    public List<Worker> findAllWorker() {
        return workerMapper.selectList(null);
    }

    @Override
    public int addWorker(Worker worker) {
        return workerMapper.insert(worker);
    }

    @Override
    public int deleteWorkerById(Integer id) {
        return workerMapper.deleteById(id);
    }

    @Override
    public int updateWorker(Worker worker) {
        return workerMapper.updateById(worker);
    }

    @Override
    public List<Worker> findByName(String name) {
        return workerMapper.selectList(new QueryWrapper<Worker>().like("name",name));
    }

    @Override
    public Worker findById(Integer id) {
        return workerMapper.selectById(id);
    }
}
